package com.gps.funnymath.domains;

import java.util.ArrayList;
import java.util.Random;

import com.gps.funnymath.concreteItems.ConcreteNoun;



public class NounDomain implements Domain{

	static Random random = new Random();
	
	ArrayList<ConcreteNoun> nouns; // all nouns in domain

	String label;
	
	public NounDomain(String label){
		
		nouns = new ArrayList<ConcreteNoun>();
		
		this.label = label;
	}
	
	public boolean add(ConcreteNoun noun){
		return nouns.add(noun);
	}
	
	public boolean remove(ConcreteNoun noun){
		return nouns.remove(noun);
	}
	
	public ConcreteNoun getRandom(){
		int index = random.nextInt(nouns.size());
		return nouns.get(index);
	}

	@Override
	public boolean contains(Object object) {
		
		if(object instanceof ConcreteNoun){
			
			for (ConcreteNoun noun : nouns){
			    if (noun.equals((ConcreteNoun)object))
			    	return true;
			}
			
		}
		
		return false;
	}
	
	
}
